<%--
  Created by IntelliJ IDEA.
  User: 00
  Date: 2018/3/13
  Time: 14:41
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@include file="/WEB-INF/jsp/comm/head.jsp"%>
    <title>Title</title>
</head>
<body>

<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            条件查询
        </div>
        <div class="panel-body">
            <form class="form-inline">
                <div class="form-group">
                    <label for="" class="control-label">任务编号：</label>
                    <input type="text" name="inspectionTaskCode" class="form-control"/>
                </div>
                <div class="form-group">
                    <label for="" class="control-label">线路管理：</label>
                    <input type="text" name="lineName"  class="form-control"/>
                </div>
                <div class="form-group">
                    <label for="" class="control-label">任务状态：</label>
                    <select name="configValueId" class="form-control">
                        <option value="-1">--请选择--</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="" class="control-label">下发人：</label>
                    <input type="text" name="issuedByName" class="form-control"/>
                </div>

                <div class="form-group">
                    <button type="button" class="btn btn-danger" onclick="zxhz()"><i class="glyphicon glyphicon-search"></i> 查询</button>
                </div>
            </form>
        </div>
    </div>


    <table id="table"
               data-toggle="table"
               data-url="${ctx}/xj/qxdj/zxshou"
               data-striped="true"
               data-pagination="true"
               data-side-pagination="server"
               data-page-size="4"
               data-page-list="[4,8,12,16,20]"
               data-query-params="queryParams"
               data-toolbar="toolbar">
            <thead>

            <tr>
                <th data-field="inspectiontaskMain.inspectionTaskCode">任务编号</th>
                <th data-field="inspectiontaskMain.inspectionTaskName">任务名称</th>
                <th data-field="inspectiontaskMain.lineName">巡查路线</th>
                <th data-field="inspectiontaskMain.startPolecode">起始编号</th>
                <th data-field="inspectiontaskMain.endPolecode">终止编号</th>
                <th data-field="inspectiontaskMain.issuedByName">下发人</th>
                <th data-field="inspectiontaskMain.issuedTime">下发时间</th>
                <th data-field="inspectiontaskMain.taskStatusName" data-formatter="taskFor">任务状态</th>
                <th data-field="inspectiontaskMain.finishTime">完成任务时间</th>
                <th id="xunjian" data-events="events" data-formatter="formOpt">操作</th>
            </tr>
            </thead>
        </table>



<%@include file="/WEB-INF/jsp/comm/foot.jsp"%>
    <script src="${ctx}/static/myjs/zxhz.js"></script>
<script>


    $(function(){
        $.getJSON(ctx+"zdfp/search1",function(arr){
            $(arr).each(function(){
                var $opt=$("<option/>");
                $opt.html(this.configValueName);
                $opt.val(this.configValueId);
                $opt.appendTo("[name=configValueId]");
            });
        });
    });

    $(function(){
        $.getJSON(ctx+"xj/qxdj/search",function(arr){

        })
    })

    function taskFor(value,row){
        if(row["inspectiontaskMain"].taskStatusName=="待分配"){
            return "<span style='color: orange'>待分配</span>"
        }
        else if(row["inspectiontaskMain"].taskStatusName=="已分配"){
            return "<span style='color: blue'>已分配</span>"
        }
        else if(row["inspectiontaskMain"].taskStatusName=="执行中"){
            return "<span style='color: purple'>执行中</span>"
        }else{
            return "<span style='color: green'>已完成</span>"
        }
    }

    function formOpt(value,row){
            var getshow = `<button class="btn btn-info edit getshow glyphicon" > 查看</button> `;
            var huizhi = `<button class="btn btn-info huizhi" > 回执录入</button> `;
            var zxupdate = `<button class="btn btn-info zxupdate" > 执行</button> `;
            var update = `<button class="btn btn-info update" > 修改</button> `;
            return getshow+huizhi+zxupdate+update;
    }

    var events={
        "click .getshow":function(e,value,row){
            getshow(row);
        },
        "click .huizhi":function(e,value,row){
            huizhi(row);
        },
        "click .zxupdate":function(e,value,row){
            zxupdate(row);
        },
        "click .update":function(e,valuew,row){
           update(row);
        }
    }


    function zxupdate(row){
        $.post(ctx+"xj/qxdj/zxupdate",{id:row["id"]},function(isOk){
            toastr.warning("信息提示",isOk);
            $("#table").bootstrapTable("refresh");
        })
    }


    function huizhi(row){
        var url="sys/get/getSearch?lineCode="+row["lineCode"];
        location.href=url;
    }



</script>
</body>
</html>
